package com.huikeportal.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.huikeportal.dao.ChangePwdMapper;
import com.huikeportal.model.ChangePwd;
import com.huikeportal.model.MessageCommon;
import com.huikeportal.service.ChangePwdService;

@Service("changePwdService")
public class ChangePwdServiceImpl implements ChangePwdService {

	@Autowired
	private ChangePwdMapper changePwdMapper;
	public boolean paswordIsRight(ChangePwd changePwd) throws Exception {
		// TODO Auto-generated method stub
		int count=changePwdMapper.paswordIsRight(changePwd);
		if(count==0){
			return false;
		}else
		{
			return true;
		}
	}

	public MessageCommon updatePwd(ChangePwd changePwd) throws Exception {
		// TODO Auto-generated method stub
		MessageCommon messageCommon = new MessageCommon();
		if(!paswordIsRight(changePwd)){
			messageCommon.setFlag(false);
			messageCommon.setMessage("原密码错误！");
		}else{
			changePwdMapper.updatePwd(changePwd);
			messageCommon.setFlag(true);
			messageCommon.setMessage("修改密码成功！");
		}
		return messageCommon;
	}

}
